import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86132
 * Date: 2022-04-26
 * Time: 20:41
 */
public class Test {
    //计算日期稻田数转换
    import java.util.*;
    public class Main{
        public static void main(String[]args){
            Scanner sc=new Scanner(System.in);
            while(sc.hasNext()){
                int y=sc.nextInt();
                int m=sc.nextInt();
                int d=sc.nextInt();
                int sum=0;//用来存天数
                int[] day={31,59,90,120,151,181,212,243,273,304,334,365};
                if(m>=2){
                    sum+=day[m-2];//吧截至到前一个月的天数加上
                }
                sum+=d;//再加上当月的天数
                if(m>2){
                    if(y%400==0||y%4==0&&y%100!=0){//说明是闰年，2月多加1天
                        sum+=1;
                    }
                }
                System.out.println(sum);
            }
        }
    }
}
